package com.mhc.suzuki.controller;

import com.mhc.suzuki.constant.ErrorCodeEnum;
import com.mhc.suzuki.constant.OrderStatusEnum;
import com.mhc.suzuki.vo.OrderStatusVO;
import com.subaru.common.entity.BizResult;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * 公用服务
 * Created by kanon on 17/9/13 19:18.
 */
@Slf4j
@RestController
@RequestMapping(value = "/commonData")
public class CommonDataController {

    /**
     * 获取订单状态
     *
     * @return
     */
    @ApiOperation(value = "获取订单状态", notes = "")
    @RequestMapping(value = {"/orderStatus/"}, method = RequestMethod.GET)
    @ApiImplicitParams({
    })
    public BizResult<List<OrderStatusVO>> getOrderStatus() {
        List<OrderStatusVO> orderStatusVOList = new ArrayList<>();
        OrderStatusEnum[] enums = OrderStatusEnum.values();
        for (OrderStatusEnum anEnum : enums) {
            OrderStatusVO orderStatusVO = new OrderStatusVO();
            orderStatusVO.setCode(anEnum.getCode());
            orderStatusVO.setMsg(anEnum.getMsg());
            orderStatusVOList.add(orderStatusVO);
        }

        return BizResult.create(orderStatusVOList, ErrorCodeEnum.SUCCESS.getErrCode(), ErrorCodeEnum.SUCCESS.getErrMsg());
    }
}